package tech.aistar.clothesspringboot.service.impl;


import cn.hutool.core.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.aistar.clothesspringboot.mapper.RentOrderMapper;
import tech.aistar.clothesspringboot.pojo.RentOrder;
import tech.aistar.clothesspringboot.pojo.result.ResultReturn;
import tech.aistar.clothesspringboot.service.RentOrderService;

import java.util.List;
import java.util.UUID;

@Service
public class RentOrderServiceImpl implements RentOrderService {
    @Autowired
    private RentOrderMapper rentOrderMapper;
    @Override
    public List<RentOrder> getRentOrderByUserId(Integer userId) {
        return rentOrderMapper.getRentOrderByUserId(userId);
    }

    @Override
    public ResultReturn insertRentOrderByUserId(RentOrder rentOrder) {
        String orderNo = "RENT" + RandomUtil.randomNumbers(11);
        rentOrder.setOrderNo(orderNo);
        int i = rentOrderMapper.insertRentOrderByUserId(rentOrder);
        if(i>0){
            return ResultReturn.success();
        }
        return ResultReturn.fail("添加失败");
    }
}
